﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autofac;

namespace System
{
    public partial class ContainerManager
    {
        /// <summary>
        /// Make sure dispose the scope
        /// </summary>
        /// <param name="tag"></param>
        /// <returns></returns>
        public ILifetimeScope BeginLifetimeScope(object tag)
        {
            var lifetimeScope = _container.BeginLifetimeScope(tag);
            return lifetimeScope;
        }
        /// <summary>
        /// Get scop by default tag of WebApi or Mvc.
        /// but the scop is different  lifetime of WebApi's scope,so you must sure dispose the scope by yourself
        /// </summary>
        /// <returns></returns>
        public ILifetimeScope BeginLifetimeScope()
        {
            return BeginLifetimeScope("AutofacWebRequest");
        }
    }
}
